#coding=UTF-8 
from chinacQA.Static import testEnvtConf
from chinacQA.TestCase import TestCase
from chinacQA.TestLink_TestCase import assertBool
from chinacQA.TestLink_TestCase import getConfigure
from chinacQA.TestLink_TestCase import setConfigure

from chinacQA.TestLink_TestCase import waitMoment
from template.NeoCUUI_ENG import *

import random

def generateRom():
    seed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
    sa = []
    for i in range(8):
        sa.append(random.choice(seed))
    salt = ''.join(sa)
    return salt

def generateV():
    return random.choice(['Project','Shared'])

def Login():
    idusername.text='kyo'
    idpassword.text="Abcd12345"
    loginBtn.click()

def STEP_AddCG():
    for i in range(10000):
        AlarmTab.click()
        ContackGroup.click()
    
        groups_action_create.click()
        idname.text = "CG_"+generateRom()
        idproject.select(text="kyo_project")
        idvisibility.select(text=generateV())
        CreateCGButton.click()

def STEP_DeleteCG():
    
    
    AlarmTab.click()
    ContackGroup.click()
    heads = groups.getHeads()
    columnAction = heads.index('Actions')
    for i in range(10000):
        ContackGroup.click()
        waitMoment(2)
        actioncell=groups.getCell(0,columnAction)
        menu_ul = actioncell.find_element("xpath",".//div")
        menu_ul.click()
        menubuttons = menu_ul.find_elements("xpath",".//li")
        for button in menubuttons:
            if (button.text.strip()=="Delete"):
                button.click()
                DeleteConfirm.click()
                break

    

TC_000_NeoCUInitial  = TestCase("Neocu Eng Initialize")
TC_000_NeoCUInitial.AddStep(Login)
# TC_000_NeoCUInitial.AddStep(STEP_AddCG)
TC_000_NeoCUInitial.AddStep(STEP_DeleteCG)


if __name__ == "__main__":
    TC_000_NeoCUInitial.run()